package com.frank.biz.ryjbxx.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.frank.common.annotation.Log;
import com.frank.common.enums.BusinessType;
import com.frank.biz.ryjbxx.domain.BizRyjbxx;
import com.frank.biz.ryjbxx.service.IBizRyjbxxService;
import com.frank.common.core.controller.BaseController;
import com.frank.common.core.domain.AjaxResult;
import com.frank.common.utils.poi.ExcelUtil;
import com.frank.common.core.page.TableDataInfo;

/**
 * 人员信息Controller
 * 
 * @author frank
 * @date 2024-09-10
 */
@Controller
@RequestMapping("/biz/ryjbxx")
public class BizRyjbxxController extends BaseController
{
    private String prefix = "biz/ryjbxx";

    @Autowired
    private IBizRyjbxxService bizRyjbxxService;

    @RequiresPermissions("biz:ryjbxx:view")
    @GetMapping()
    public String ryjbxx()
    {
        return prefix + "/ryjbxx";
    }

    /**
     * 查询人员信息列表
     */
    @RequiresPermissions("biz:ryjbxx:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(BizRyjbxx bizRyjbxx)
    {
        startPage();
        bizRyjbxx.setCreateBy(getLoginName());
        List<BizRyjbxx> list = bizRyjbxxService.selectBizRyjbxxList(bizRyjbxx);
        return getDataTable(list);
    }

    /**
     * 导出人员信息列表
     */
    @RequiresPermissions("biz:ryjbxx:export")
    @Log(title = "人员信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(BizRyjbxx bizRyjbxx)
    {
        bizRyjbxx.setCreateBy(getLoginName());
        List<BizRyjbxx> list = bizRyjbxxService.selectBizRyjbxxList(bizRyjbxx);
        ExcelUtil<BizRyjbxx> util = new ExcelUtil<BizRyjbxx>(BizRyjbxx.class);
        return util.exportExcel(list, "人员信息数据");
    }

    /**
     * 新增人员信息
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存人员信息
     */
    @RequiresPermissions("biz:ryjbxx:add")
    @Log(title = "人员信息", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(BizRyjbxx bizRyjbxx)
    {
        bizRyjbxx.setCreateBy(getLoginName());
        return toAjax(bizRyjbxxService.insertBizRyjbxx(bizRyjbxx));
    }

    /**
     * 修改人员信息
     */
    @RequiresPermissions("biz:ryjbxx:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        BizRyjbxx bizRyjbxx = bizRyjbxxService.selectBizRyjbxxById(id);
        mmap.put("bizRyjbxx", bizRyjbxx);
        return prefix + "/edit";
    }

    /**
     * 修改保存人员信息
     */
    @RequiresPermissions("biz:ryjbxx:edit")
    @Log(title = "人员信息", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(BizRyjbxx bizRyjbxx)
    {
        bizRyjbxx.setUpdateBy(getLoginName());
        return toAjax(bizRyjbxxService.updateBizRyjbxx(bizRyjbxx));
    }

    /**
     * 删除人员信息
     */
    @RequiresPermissions("biz:ryjbxx:remove")
    @Log(title = "人员信息", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(bizRyjbxxService.deleteBizRyjbxxByIds(ids));
    }
}
